<!--
 * @Description: 节点完成(节点维护改名)
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2021-11-29 17:15:13
 * @LastEditTime: 2023-07-05 11:10:45
 * @FilePath: \cscec-pms-admin\src\views\construction\constructionSchedule\components\NodeMaintainPage.vue
-->
<template>
  <a-spin :spinning="loading">
    <!-- 前置节点信息,内控计划单独修改 -->
    <div
      v-if="apiCode === 0"
      class="front-task-info"
    >
      <p>
        <span>前置节点信息：</span>
        <i @click="frontTaskVisible = !frontTaskVisible">
          {{ frontTaskVisible ? '收起' : '展开' }}
          <a-icon :type="frontTaskVisible ? 'up' : 'down'" />
        </i>
      </p>
      <a-empty
        v-if="frontTaskVisible && frontDetailList.length === 0"
        class="front-task-empty"
      />
      <ul
        v-else
        :class="{'front-task-list-visible':frontTaskVisible}"
      >
        <li
          v-for="item in frontDetailList"
          :key="item.id"
        >
          <p>{{ item.type }}</p>
          <section>
            <span>{{ item.period }}天</span>
            <span>{{ item.planStartTime }}-{{ item.planEndTime }}</span>
          </section>
          <section>
            <i :class="color[item.statusLights]"></i>
            <span>{{ item.desc }}</span>
          </section>
        </li>
      </ul>
    </div>
    <!-- 前置节点信息,内控计划单独修改 -->
    <titleName title="节点基本信息" />
    <custom-form
      ref="form"
      :is-validate="true"
      :edit-model="''"
      :rules="rules"
      :form="form"
      :form-list="formOption"
    >
      <div slot="promptLights" class="status-list">
        <img
          v-if="form.promptLights === 1 || form.promptLights === 2"
          :src="form.promptLights === 1 ? yellowLight : redLight"
          width="20"
          hight="20"
        />
        <div
          :class="color[form.statusLights]"
          class="prompt-lights"
        />
      </div>
      <template
        slot="completeDate"
        slot-scope="{data:{formItem:{disabled}}}"
      >
        <a-date-picker
          v-model="form.completeDate"
          :placeholder="disabled?'':'请选择'"
          :disabled-date="(current)=>{return completeDateDisabled(current)}"
          :disabled="useCompleteDate"
        />
      </template>
      <template
        slot="delayTypes"
        slot-scope="{data:{formItem:{disabled}}}"
      >
        <a-tree-select
          v-model="form.delayTypes"
          placeholder="请选择逾期类别"
          :tree-data="delayTypeTree"
          :replace-fields="replaceFields"
          show-search
          multiple
          :disabled="disabled"
          :filter-tree-node="filterTreeNode"
        />
      </template>
    </custom-form>
    <template v-if="moment(form.planEndTime).diff(moment(form.completeDate), 'days') < 0">
      <titleName title="有效赶工措施" />
      <custom-form
        ref="form1"
        :is-validate="true"
        :edit-model="''"
        :rules="rules1"
        :form="form1"
        :form-list="formOption1"
      />
    </template>
    <titleName title="节点开始附件" />
    <UploadTableNew
      ref="uploadTable"
      :mode="file.mode"
      :init-file-list="file.fileList"
      :need-page="file.needPage"
      :use-add="false"
      :use-delete="false"
      :business-code="file.businessCode"
    />
    <titleName
      title="第三方完工确认单上传"
      class="margin-top"
    />
    <UploadTableNew
      ref="uploadTable"
      :mode="file1.mode"
      :init-file-list="file1.fileList"
      :need-page="file1.needPage"
      :use-add="useAdd"
      :business-code="file1.businessCode"
    />
    <titleName
      title="节点完成附件"
      style="margin-top:20px;"
    />
    <UploadTableNew
      ref="uploadTable"
      :mode="file2.mode"
      :init-file-list="file2.fileList"
      :need-page="file2.needPage"
      :use-add="useAdd"
      :business-code="file2.businessCode"
    />
    <!-- 选择审批人 -->
    <selectApprover
      :business-id="businessId"
      :process-config="setProcessConfig"
      :is-close-upper="false"
      @close="handleModalCancel(true)"
    />
    <div
      v-checkVisibleInDetail
      v-if="isAudit"
      class="page-btn-right-top"
    >
      <a-button @click="$close">关闭</a-button>
    </div>
    <!-- 选择审批人 -->
  </a-spin>
</template>
<script>
import { formOption, formOption1 } from '../model.js'
import constructionSchedule from '@/api/construction/constructionSchedule'
import { implementationManagement } from '@/api/construction/constructionCompleted'
import { TreeSelect } from 'ant-design-vue'
import { Empty } from 'ant-design-vue'
export default {
  name: 'NodeMaintainPage',
  props: {
    // 接口代码 0：总计划，2：竣工收尾计划
    apiCode: {
      type: Number,
      default: 0
    },
    // 节点信息
    source: {
      type: Object,
      default: () => {}
    },
    isAudit: {
      // 是否作为审批详情
      type: Boolean,
      default: false
    },
    loading: {
      // 加载
      type: Boolean,
      default: false
    },
    submiting: {
      // 提交
      type: Boolean,
      default: false
    }
  },
  components: {
    ATreeSelect: TreeSelect,
    AEmpty: Empty
  },
  data() {
    return {
      // 数据
      data: this.isAudit ? { type: 'detail' } : this.source,
      // 节点完成信息表单
      form: {
        planEndTime: null
      },
      // 节点完成信息校验
      rules: {
        completeDate: [{ required: true, message: '请选择实际完成时间', trigger: 'change' }],
        delayTypes: [{ required: true, message: '请选择逾期类别', trigger: 'change' }],
        delayReason: [{ required: true, message: '请选输入逾期原因', trigger: 'change' }]
      },
      // 有效赶工措施表单
      form1: {},
      // 红灯
      redLight: require('@/assets/icons/redLight.png'),
      // 黄灯
      yellowLight: require('@/assets/icons/yellowLight.png'),
      // 节点开始附件
      file: {
        // 处理操作的模式：'add'模式下，删除操作会调用文件删除接口，'edit'模式只会在表格中移除删除数据，不会调用接口
        mode: 'add',
        // 上传文件的业务编码
        businessCode: 'PM45',
        // 是否需要分页
        needPage: false,
        // 初始化文件列表
        fileList: []
      },
      // 第三方完工确认单上传
      file1: {
        // 处理操作的模式：'add'模式下，删除操作会调用文件删除接口，'edit'模式只会在表格中移除删除数据，不会调用接口
        mode: 'add',
        // 上传文件的业务编码
        businessCode: 'PM02',
        // 是否需要分页
        needPage: false,
        // 初始化文件列表
        fileList: []
      },
      // 附件信息上传
      file2: {
        // 处理操作的模式：'add'模式下，删除操作会调用文件删除接口，'edit'模式只会在表格中移除删除数据，不会调用接口
        mode: 'add',
        // 上传文件的业务编码
        businessCode: 'PM03',
        // 是否需要分页
        needPage: false,
        // 初始化文件列表
        fileList: []
      },
      // 逾期类别树
      delayTypeTree: [],
      // 逾期类别树字段替换
      replaceFields: {
        children: 'children',
        title: 'title',
        key: 'value',
        value: 'value'
      },
      // 节点维护信息
      nodeResultVO: {},
      // 责任人反馈
      feedback: '',
      // 节点名称是否有工程
      isProject: 0,
      // 是否需要限制完成时间
      isAdjustNode: false,
      // 总计划审批通过时间
      masterPlanPassTime: '',
      // 实际完成时间禁用
      useCompleteDate: false,
      // 流程配置
      processConfig: null,
      processConfig1: null,
      processConfig2: null,
      processConfig3: null,
      //点击提交发送流程配置值
      setProcessConfig: null,
      // 业务id
      businessId: null,
      // 流程类型
      secondLevelType: null,
      // 前置节点信息显示隐藏
      frontTaskVisible: false,
      // 前置节点信息列表
      frontDetailList: [],
      // 节点颜色
      color: {
        0: 'class-slider-0',
        1: 'class-slider-1',
        2: 'class-slider-2',
        3: 'class-slider-3',
        4: 'class-slider-4'
      }
    }
  },
  computed: {
    // 节点完成信息表单项
    formOption() {
      this.$checkRequireItem()
      // 节点状态(0：待进行/1：正进行/2：审批中/3：逾期未完成/4：按期完成/5：逾期完成)
      // 查看(基本信息)
      const info = [0, 1, 3]
      const list = this.$clone(formOption)
      return list
        .filter((el) => {
          if (this.feedback === '-' && (el.keyName === 'canComplete' || el.keyName === 'feedbackContent')) {
            return false
          }
          if (this.feedback === '未反馈' && el.keyName === 'feedbackContent') {
            return false
          }
          // 施工进度总计增加的字段(竣工时不显示)
          if (this.apiCode !== 0 && el.keyName === 'actualStartDate') {
            return false
          }
          // 查看
          if (this.data.type === 'detail') {
            // 查看(基本信息: 0,1,3)
            if (info.includes(this.data.nodeStatus) && !this?.nodeResultVO?.delayTypes) {
              const list = ['creatorName', 'createTime', 'delayTypes', 'delayReason']
              if (!list.includes(el.keyName)) {
                return el
              }
            } else {
              if (el.keyName === 'completeDate') {
                el.label = '实际完成时间'
                this.rules.completeDate[0].message = '请选输入实际完成时间'
              }
              if (this.moment(this.form.planEndTime).diff(this.moment(this.form.completeDate), 'days') >= 0 || this.data.nodeStatus === 0) {
                // 不逾期
                // const list = ['creatorName', 'createTime', 'delayTypes']
                const list = ['delayTypes']
                if (el.keyName === 'delayReason') {
                  el.label = '备注'
                  this.rules.delayReason[0].message = '请选输入备注'
                }
                if (!list.includes(el.keyName)) {
                  return el
                }
              } else {
                if (el.keyName === 'delayReason') {
                  el.label = '逾期原因'
                  this.rules.delayReason[0].message = '请选输入逾期原因'
                }
                // 逾期
                return el
              }
            }
          } else {
            // 维护
            if (el.keyName === 'completeDate') {
              el.label = '实际完成时间'
              this.rules.completeDate[0].message = '请选输入实际完成时间'
            }
            if (this.isAdjustNode) {
              if (this.moment(this.form.planEndTime).diff(this.moment(this.form.completeDate), 'days') >= 0) {
                // 不逾期
                // const list = ['creatorName', 'createTime', 'delayTypes']
                const list = ['delayTypes']
                if (el.keyName === 'delayReason') {
                  el.label = '备注'
                  this.rules.delayReason[0].message = '请选输入备注'
                }
                if (!list.includes(el.keyName)) {
                  return el
                }
              } else {
                if (el.keyName === 'delayReason') {
                  el.label = '逾期原因'
                  this.rules.delayReason[0].message = '请选输入逾期原因'
                }
                // 逾期
                return el
              }
            } else {
              if (this.moment(this.form.planEndTime).diff(this.moment(this.form.completeDate), 'days') >= 0 || this.data.nodeStatus === 0) {
                // 不逾期
                // const list = ['creatorName', 'createTime', 'delayTypes']
                const list = ['delayTypes']
                if (el.keyName === 'delayReason') {
                  el.label = '备注'
                  this.rules.delayReason[0].message = '请选输入备注'
                }
                if (!list.includes(el.keyName)) {
                  return el
                }
              } else {
                if (el.keyName === 'delayReason') {
                  el.label = '逾期原因'
                  this.rules.delayReason[0].message = '请选输入逾期原因'
                }
                // 逾期
                return el
              }
            }
          }
        })
        .map((el) => {
          // 查看
          if (this.data.type === 'detail') {
            el.disabled = true
          } else {
            // 维护
            // 节点状态(0：待进行/1：正进行/2：审批中/3：逾期未完成/4：按期完成/5：逾期完成)
            if (this.data.nodeStatus === 0 || this.data.nodeStatus === 1) {
              const arr = ['completeDate', 'delayTypes', 'delayReason']
              if (!arr.includes(el.keyName)) {
                el.disabled = true
              } else {
                el.disabled = false
              }
            } else if (this.data.nodeStatus === 3) {
              const arr = ['completeDate', 'delayTypes', 'delayReason']
              if (!arr.includes(el.keyName)) {
                el.disabled = true
              } else {
                el.disabled = false
              }
            } else {
              el.disabled = true
            }
          }
          return el
        })
    },
    // 有效赶工措施表单项
    formOption1() {
      // 查看
      const list = this.$clone(formOption1)
      if (this.data.type === 'detail') {
        return list.map((el) => {
          const item = this.$clone(el)
          item.disabled = true
          return item
        })
      } else {
        return list
      }
    },
    // 有限赶工措施表单校验
    rules1() {
      const obj = {}
      formOption1.forEach((item) => {
        if (item.rules) {
          obj[item.keyName] = item.rules
        }
      })
      return obj
    },
    // 文件上传按钮
    useAdd() {
      if (this.data.type === 'detail') {
        return (this.data.nodeStatus === 4 || this.data.nodeStatus === 5) && !this.isAudit && this.data.isIndividual === 1
      } else {
        return (this.data.nodeStatus === 0 || this.data.nodeStatus === 1 || this.data.nodeStatus === 3) && !this.isAudit && this.data.isIndividual === 1
      }
    }
  },
  watch: {
    'form1.laborResFee'() {
      this.computeRushFee()
    },
    'form1.equipResFee'() {
      this.computeRushFee()
    },
    'form1.materialResFee'() {
      this.computeRushFee()
    },
    'form1.safetyMeasureFee'() {
      this.computeRushFee()
    }
  },
  async created() {
    //获取通过获取流程配置值
    // 招采
    this.processConfig = await this.$getConfigFn('node_maintain_mining')
    // 设计
    this.processConfig1 = await this.$getConfigFn('node_maintain_design')
    // 前期准备/工程/验收取证
    this.processConfig2 = await this.$getConfigFn('node_maintain_project')
    // 竣工收尾计划节点维护
    this.processConfig3 = await this.$getConfigFn('schedule_completion_plan_node_maintain')
  },
  mounted() {
    this.getDelayType()
    if (this.isAudit) {
      this.getData()
    }
  },
  methods: {
    /**
     * @description: 格式化时间
     * @param {object/string} date 时间对象或字符串
     * @param {boolean} toMoment 是否转换为Moment
     * @return {object} moment时间格式
     */
    formatDate(date, toMoment = true) {
      if (date?._isAMomentObject) {
        return toMoment ? date : date.format('YYYY-MM-DD')
      } else {
        return toMoment ? this.moment(date) : date
      }
    },
    /**
     * @description: 计算预计赶工费用
     * @param {void}
     * @return {void}
     */
    computeRushFee() {
      // 解决浮点加法运算精度问题
      const { laborResFee, equipResFee, materialResFee, safetyMeasureFee } = this.form1
      const arr = [laborResFee ?? 0, equipResFee ?? 0, materialResFee ?? 0, safetyMeasureFee ?? 0]
      let l = []
      arr.forEach((el) => {
        l.push(el.toString().split('.')[1]?.length || 0)
      })
      const lng = Math.max(...l)
      let num = 0
      arr.forEach((el) => {
        num += el * Math.pow(10, lng)
      })
      this.form1.rushFee = num / Math.pow(10, lng)
    },
    /**
     * @description:
     * 内控计划调整节点后，新增的和调整了的节点，进行节点维护时，不使用逾期的规则（总计划编辑已有相同的规则）
     * 计划完成时间早于审批通过时间不做限制
     * 1.当前时间在计划完成时间之前，节点实际完成时间可以随便选（好像目前改为了最迟只能选择到当前时间）；
     * 2.当前时间在计划完成时间之后，但在10天内，节点实际完成时间可以最早选择到计划完成时间，最迟选择到当前时间；
     * 3.当前时间在计划完成时间之后，超过10天以后，节点实际完成时间默认为当前时间，不能进行选择。
     * @param {object} current 当前时间对象
     * @return {void}
     */
    completeDateDisabled(current) {
      const currentDate = this.moment(current).format('YYYY-MM-DD')
      const nowDate = this.moment().format('YYYY-MM-DD')
      const endDate = this.moment(this.form.planEndTime).format('YYYY-MM-DD')
      const date = this.moment(endDate).diff(nowDate, 'days')
      const passTimeDate = this.moment(this.masterPlanPassTime).format('YYYY-MM-DD')
      if (!!this.isAdjustNode || (!!this.masterPlanPassTime && this.moment(endDate).diff(passTimeDate, 'day') <= 0)) {
        return current && this.moment(currentDate).diff(nowDate, 'days') > 0
      } else {
        if (date >= 0) {
          return current && this.moment(currentDate).diff(nowDate, 'days') > 0
        } else if (date < 0 && date >= -2){
          return current && (this.moment(currentDate).diff(nowDate, 'days') > 0 || this.moment(currentDate).diff(endDate, 'days') < 0)
        } else {
          return current && (this.moment(currentDate).diff(nowDate, 'days') != 0)
        }
      }
    },
    /**
     * @description: 获取逾期类型
     * @param {void}
     * @return {void}
     */
    getDelayType() {
      constructionSchedule.labelTreeList({ pageNo: 1, pageSize: 1000, type: 11 }).then(({ code, data }) => {
        if (code === 200) {
          this.delayTypeTree = data
          this.delayTypeTree.forEach(item=>{
            item['disabled'] = false
          })
        }
      })
    },
    /**
     * @description: 获取节点维护信息
     * @param {void}
     * @return {void}
     */
    getData() {
      this.$emit('update:loading', true)
      let fun = void 0
      if (this.isAudit) {
        switch (this.$route.query.businessType) {
          case '105': {
            fun = constructionSchedule.workWithResult
            break
          }
          case '125': {
            fun = implementationManagement.workWithResult
            break
          }
        }
      } else {
        switch (this.apiCode) {
          case 0: {
            fun = constructionSchedule.workWithResult
            break
          }
          case 2: {
            fun = implementationManagement.workWithResult
            break
          }
        }
      }
      fun(this.isAudit ? this.$route.query.businessId : this.data.id)
        .then(
          ({
            code,
            data: {
              feedback,
              projectName,
              businessMatters,
              phaseCategory,
              controlLevelName,
              planStartTime,
              planEndTime,
              promptLights,
              statusLights,
              nodeStatusName,
              isDeleteFile,
              nodeResultVO,
              verifyFiles,
              completeStandard,
              period,
              completeTime,
              firstResName,
              directResPerList,
              nodeFeedBackVO,
              isProject,
              isAdjustNode,
              dutySubUnit,
              masterPlanPassTime,
              secondLevelType,
              frontDetailList,
              nodeStartResultVO,
              startCreateName,
              startCreateTime
            }
          }) => {
            if (code === 200) {
              this.businessId = this.isAudit ? null : this.data.id
              this.nodeResultVO = nodeResultVO
              this.feedback = feedback
              this.isProject = isProject
              this.isAdjustNode = isAdjustNode
              this.masterPlanPassTime = masterPlanPassTime
              this.secondLevelType = secondLevelType
              this.frontDetailList = frontDetailList
              this.form = {
                projectName,
                businessMatters,
                phaseCategory,
                controlLevelName,
                planStartTime,
                planEndTime,
                promptLights,
                statusLights,
                nodeStatusName,
                completeDate: nodeResultVO?.completeDate || '',
                verifyFiles,
                completeStandard,
                delayReason: nodeResultVO?.delayReason,
                remark: nodeResultVO?.delayReason,
                delayTypes: nodeResultVO?.delayTypes,
                period,
                completeTime,
                firstResName,
                directResPerList: (directResPerList || []).map((el) => el.label).join(','),
                canComplete: feedback,
                feedbackContent: nodeFeedBackVO?.feedbackContent,
                creatorName: nodeResultVO?.creatorName ?? JSON.parse(sessionStorage.getItem('ycloud-user_info')).name,
                createTime: nodeResultVO?.createTime ? this.moment(nodeResultVO?.createTime).format('YYYY-MM-DD') : this.moment().format('YYYY-MM-DD'),
                dutySubUnit: dutySubUnit
              }
              // 施工进度总计增加的字段
              if (this.apiCode === 0) {
                this.form = {
                  ...this.form,
                  actualStartDate: nodeStartResultVO?.actualStartDate,
                  startCreateName,
                  startCreateTime
                }
              }
              this.form1 = {
                laborResFee: nodeResultVO?.rushMeasure?.laborResFee,
                equipResFee: nodeResultVO?.rushMeasure?.equipResFee,
                materialResFee: nodeResultVO?.rushMeasure?.materialResFee,
                safetyMeasureFee: nodeResultVO?.rushMeasure?.safetyMeasureFee,
                rushFee: nodeResultVO?.rushMeasure?.rushFee,
                laborRes: nodeResultVO?.rushMeasure?.laborRes,
                equipRes: nodeResultVO?.rushMeasure?.equipRes,
                materialRes: nodeResultVO?.rushMeasure?.materialRes,
                safetyMeasure: nodeResultVO?.rushMeasure?.safetyMeasure
              }
              // 当前时间在计划完成时间之后，超过10天以后，节点实际完成时间默认为当前时间，不能进行选择
              if (this.moment().diff(this.moment(this.form.planEndTime), 'day') >= 10 && this.data.type !== 'detail') {
                this.form.completeDate = this.moment()
              }
              //设置附件
              // 施工进度总计增加的附件
              if (this.apiCode === 0) {
                this.file.fileList =
                  nodeStartResultVO?.startFileList.map((el) => {
                    el.useDelete = (this.source?.type || 'detail') === 'detail' ? false : isDeleteFile
                    return el
                  }) || []
              }
                if( nodeStartResultVO.thirdInfoList && nodeStartResultVO.thirdInfoList.length) {
                  this.file1.fileList =
                    nodeStartResultVO?.thirdInfoList.map((el) => {
                      el.useDelete = (this.source?.type || 'detail') === 'detail' ? false : isDeleteFile
                      return el
                    }) || []
                }  else  {
                  this.file1.fileList =
                    nodeResultVO?.thirdInfoList.map((el) => {
                      el.useDelete = (this.source?.type || 'detail') === 'detail' ? false : isDeleteFile
                      return el
                    }) || []
                }

                if(nodeStartResultVO.otherInfoList && nodeStartResultVO.otherInfoList.length) {
                  this.file2.fileList =
                    nodeStartResultVO?.otherInfoList.map((el) => {
                      el.useDelete = (this.source?.type || 'detail') === 'detail' ? false : isDeleteFile
                      return el
                    }) || []

                } else  {
                  this.file2.fileList =
                    nodeResultVO?.otherInfoList.map((el) => {
                      el.useDelete = (this.source?.type || 'detail') === 'detail' ? false : isDeleteFile
                      return el
                    }) || []
                }

              // 实际完成时间是否禁用
              // 是否查看
              if (this.data.type === 'detail') {
                this.useCompleteDate = true
              } else {
                this.useCompleteDate = false
              }
            }
          }
        )
        .finally(() => {
          this.$emit('update:loading', false)
        })
    },
    /**
     * @description: 提交审批
     * @param {void}
     * @return {void}
     */
    handleSubmit() {
      try {
        const vm = this
        if (vm.data.type === 'detail') {
          this.$confirm({
            title: '是否确定提交?',
            content: '',
            onOk() {
              vm.$emit('update:submiting', true)
              // 查看
              let fun = void 0
              switch (vm.apiCode) {
                case 0: {
                  fun = constructionSchedule.nodeMaintainFile
                  break
                }
                case 2: {
                  fun = implementationManagement.nodeMaintainFile
                  break
                }
              }
              fun({
                workId: vm.data.id,
                thirdInfoList: vm.file1.fileList,
                otherInfoList: vm.file2.fileList
              })
                .then(({ code }) => {
                  if (code === 200) {
                    vm.$message.success('提交成功！')
                    vm.handleModalCancel(true)
                  }
                })
                .finally(() => {
                  vm.$emit('update:submiting', false)
                })
            }
          })
        } else {
          // 节点完成(维护修改而来)
          vm.$refs.form.validate((valid) => {
            if (valid) {
              if (vm.data.nodeStatus === 5 || (vm.data.nodeStatus === 2 && vm.nodeResultVO.delayTypes)) {
                vm.$refs.form1.validate((valid1) => {
                  if (valid1) {
                    vm.submitFun()
                  }
                })
              } else {
                vm.submitFun()
              }
            }
          })
        }
      } catch (error) {
        console.log(error)
      }
    },
    /**
     * @description: 提交
     * @param {void}
     * @return {void}
     */
    submitFun() {
      if (this.isProject === 1) {
        if (this.file1.fileList.length > 0) {
          this.submitMethod()
        } else {
          this.$message.warning('请先上传第三方完工确认单附件！')
        }
      } else {
        this.submitMethod()
      }
    },
    /**
     * @description: 提交方法
     * @param {void}
     * @return {void}
     */
    submitMethod() {
      try {
        if (this.apiCode === 0) {
        // 内控计划
        switch (this.secondLevelType) {
          case 1:
            // 招采
            this.setProcessConfig = this.processConfig
            break
          case 2:
            // 设计
            this.setProcessConfig = this.processConfig1
            break
          default:
            // 前期准备/工程/验收取证
            this.setProcessConfig = this.processConfig2
        }
      } else {
        // 竣工收尾计划
        this.setProcessConfig = this.processConfig3
      }
      this.submitApprovalConfirm(this.setProcessConfig, (flag) => {
        if (!flag) return
        let params = {}
        if (this.data.nodeStatus === 1 && this.isAdjustNode !== true) {
          const { completeDate, delayReason } = this.form
          params = {
            completeDate: this.formatDate(completeDate, false),
            delayReason,
            workId: this.data.id,
            thirdInfoList: this.file1.fileList || [],
            otherInfoList: this.file2.fileList || []
          }
        } else {
          const { completeDate, delayReason, delayTypes } = this.form
          params = {
            completeDate: this.formatDate(completeDate, false),
            delayReason,
            delayTypes,
            rushMeasure: this.form1,
            thirdInfoList: this.file1.fileList || [],
            otherInfoList: this.file2.fileList || [],
            workId: this.data.id
          }
        }
        this.$emit('update:submiting', true)
        let fun = void 0
        switch (this.apiCode) {
          case 0: {
            fun = constructionSchedule.nodeMaintain
            break
          }
          case 2: {
            fun = implementationManagement.nodeMaintain
            break
          }
        }
        fun(params)
          .then(({ code }) => {
            if (code === 200) {
              // 设置businessId触发审批人弹框
              this.businessId = this.data.id
              this.$message.success('提交成功！')
              // 不选择审批人时二次弹框手动关闭
              if (parseInt(this.setProcessConfig) === 4) {
                this.handleModalCancel(true)
              }
            }
          })
          .finally(() => {
            this.$emit('update:submiting', false)
          })
      })
      } catch (error) {
        console.log(error)
      }
    },
    /**
     * @description: 下拉树形框搜索过滤
     * @param {string} input 输入值
     * @param {object} option 下拉对象
     * @return {boolean} 是否符合过滤条件
     */
    filterTreeNode(input, treeNode) {
      return treeNode.componentOptions.propsData.title.toLowerCase().indexOf(input.toLowerCase()) >= 0
    },
    /**
     * @description: 关闭
     * @return {void}
     */
    handleclose() {
      this.form = {}
      this.form1 = {}
      this.file.fileList = []
      this.file1.fileList = []
      this.file2.fileList = []
    },
    /**
     * @description: 关闭模态框
     * @param {boolean} 是否需要刷新
     * @return {void}
     */
    handleModalCancel(refresh = false) {
      this.handleclose()
      this.$emit('handleModalCancel', refresh)
    }
  }
}
</script>
<style lang="less" scoped>
.status-list{
  display: flex;
  align-items: center;
  margin-top: 7px;
  img{
    margin-right: 10px;
  }
}
.prompt-lights {
  width: 59px;
  height: 23px;
  display: flex;
  align-items: center;
  justify-content: center;
}
// .class-0 {
// background-color: #d1d1d1;
// }
// .class-1 {
// background-color: #fff;
// }
.class-2 {
  background-color: #f85c62;
}
.class-3 {
  background-color: #1dc682;
}
.class-4 {
  background-color: #ffced0;
}
.front-task-info {
  > p {
    margin: 0;
    user-select: none;
    i {
      font-style: normal;
      color: #1890ff;
      cursor: pointer;
    }
  }
  > ul {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    height: 0;
    overflow: hidden;
    li {
      border: 1px solid #e8e8e8;
      border-radius: 4px;
      padding: 1em;
      width: calc(50% - 0.5em);
      margin-top: 1em;
      p {
        margin: 0;
      }
      section {
        margin-top: 0.5em;
        display: flex;
        align-items: center;
        span {
          margin-left: 10px;
        }
        span:nth-of-type(1) {
          margin-left: 0;
        }
        i {
          display: inline-block;
          width: 24px;
          height: 14px;
          margin-right: 10px;
        }
      }
    }
    li:nth-of-type(odd) {
      margin-right: 1em;
    }
  }
  .front-task-list-visible {
    height: auto;
  }
}
.front-task-empty {
  margin-bottom: 1em;
}
.margin-top {
  margin-top: 20px;
}
</style>

